package com.itheima.homework8.secondwork;

import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Car> ts=new TreeSet<>(new Comparator<Car>() {
            @Override
            public int compare(Car o1, Car o2) {
                int result=o1.getSaleNumber()-o2.getSaleNumber();
                result=result==0? Double.compare(o1.getPrice(),o2.getPrice()):result;
                result=result==0?(o1.getName().compareTo(o2.getName())):result;
                return result;
            }
        });
        ts.add(new Car("benchi",300000,2000));
        ts.add(new Car("baoma",300000,2500));
        ts.add(new Car("aodi",250000,3000));
        ts.add(new Car("baoshijie",500000,2000));
        ts.add(new Car("wulinghongguang",100000,8000));
        ts.add(new Car("changcheng",100000,8000));
        ts.add(new Car("lanbojini",900000,1000));
   ts.forEach(s->{
       System.out.println("s = " + s);
   });


    }
}
